/**
 * 红包记录页面js
 * 版权所有：上海戈品投资管理有限公司
 *   author king
     功能说明：红包记录页面
     创建日期：2015-10-12
     修改记录：
     备注说明：
 */

$(document).ready(function() {
	showRedPackInterfaceList();
	 $(".date").datepicker({
	        todayBtn: "linked",
	        keyboardNavigation: false,
	        forceParse: false,
	        calendarWeeks: true,
	        autoclose: true
	    });
});

/**
 * 查询红包记录
 * @returns
 */
var showRedPackInterfaceList = function(){

    var sendTime = $("#sendTime").val();
	var userId = $("#userId").val();
	var sendStatus=$("#sendStatus").val();//发放奖励状态
	var name_wx = $("#name_wx").val();
	var real_name = $("#real_name").val();
	
	var datas =  {"p":"redPackManage","m":"interList","sendTime":sendTime,"userId":userId,"sendStatus":sendStatus,"name_wx":name_wx ,"real_name":real_name};
	var columnDefine = {"id":"ID","userId":"用户ID","name_wx":"昵称","real_name":"真实姓名","type":"类型","total_amount":"发放金额","result_code":"发放状态","err_code":"错误代码","err_code_des":"错误信息","create_time":"创建时间"};
	
	var formatters={
	            "create_time": function (column, rowData)
	            {
    				return timeFormatTrans(rowData.create_time);
	            },
	            "total_amount": function (column, rowData)
	            {
	            	return (rowData.total_amount)/100;
	            },
	            "type": function (column, rowData)
	            {
	            	return rowData.type == 1 ? "快递员":"用户";
	            }
	 };
	 var buttons =''; //操作按钮
		buttons+='<p>';
		buttons+='</p>';
	   hui.pager('service',datas ,"dataList", columnDefine , formatters , buttons ); //分页查询
};

var getTheSureTime=function(emp){
	return emp>9?emp:"0"+emp;
}
//时间格式转换
var timeFormatTrans=function(time){
	if(time)
	{
		var newTime= new Date(time);
		var rowText=newTime.getFullYear()+'-'+getTheSureTime((newTime.getMonth()+1))+'-'
		+getTheSureTime(newTime.getDate())+' '+getTheSureTime(newTime.getHours())+':'
		+getTheSureTime(newTime.getMinutes())+':'+getTheSureTime(newTime.getSeconds());
		return rowText;
	}
	else
	{
		return '';
	}	

};



